package com.info;

import java.util.ArrayList;

public class ClassInfo implements InfoIf{
	
	public static final int FAST_PROGRESS = 0;
	public static final int NORMAL_PROGRESS = 1;
	public static final int SLOW_PROGRESS = 2;
	
	public static final int MAX_ATTACKS = 4;
	
	private String description;
	private String name;
	private int[] abilityMod;
	private int attackProgress;
	private int fortProgress;
	private int refProgress;
	private int willProgress;
	private int skillPerLevel;
	private int hitDie;
	
	private ArrayList<SkillInfo> classSkills;

	public void setDescription(String description) {
		this.description = description;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setAbilityMod(int[] abilityMod) {
		this.abilityMod = abilityMod;
	}

	public void setAttackProgress(int attackProgress) {
		this.attackProgress = attackProgress;
	}

	public void setFortProgress(int fortProgress) {
		this.fortProgress = fortProgress;
	}

	public void setRefProgress(int refProgress) {
		this.refProgress = refProgress;
	}

	public void setWillProgress(int willProgress) {
		this.willProgress = willProgress;
	}

	public void setSkillPerLevel(int skillPerLevel) {
		this.skillPerLevel = skillPerLevel;
	}

	public void setHitDie(int hitDie) {
		this.hitDie = hitDie;
	}

	public void setClassSkills(ArrayList<SkillInfo> classSkills) {
		this.classSkills = classSkills;
	}

	public String getName() {
		return name;
	}

	public int hashCode(){
		return getName().hashCode();
	}
	
	public String getDescription() {
		return description;
	}

	public int[] getAbilityMod() {
		return abilityMod;
	}

	public int[] getAttackBonus(int level) {
		int attacks[] = new int[MAX_ATTACKS];
		switch(attackProgress){
		case FAST_PROGRESS:
			attacks[0] = level;
			break;
		case NORMAL_PROGRESS:
			attacks[0] = (int)Math.floor(level * 0.75);
			break;
		case SLOW_PROGRESS:
			attacks[0] = (int)Math.floor(level * 0.5);
			break;
		}
		attacks[1] = Math.max(0, attacks[0] - 5);
		attacks[2] = Math.max(0, attacks[0] - 10);
		attacks[3] = Math.max(0, attacks[0] - 15);
		return attacks;
	}
	
	private int calculateSaveScore(int progression, int level){
		switch(progression){
		case NORMAL_PROGRESS:
			return (int)(level / 2) + 2;
		case SLOW_PROGRESS:
			return (int)(level / 3);
		}
		return 0;
	}

	public int getFortitudeSave(int level) {
		return calculateSaveScore(fortProgress, level); 
	}

	public int getReflexSave(int level) {
		return calculateSaveScore(refProgress, level);
	}

	public int getWillSave(int level) {
		return calculateSaveScore(willProgress, level);
	}

	public int getSkillPerLevel() {
		return skillPerLevel;
	}

	public int getHitDie() {
		return hitDie;
	}

	public ArrayList<SkillInfo> getClassSkills() {
		return classSkills;
	}
	
	public boolean isClassSkill(SkillInfo skill){
		return classSkills.contains(skill);
	}

	@Override
	public BonusInfo getBonus(Object info, String condition) {
		return BonusInfo.NO_BONUS;
	}

}
